#include "MessageReceiver.h"
#include "../Shared/MessageFactory.h"
#include "../Shared/Message.h"
#include "../Shared/EvaluationSetMessageDispatcher.h"

MessageReceiver::MessageReceiver(): TCPServer(44444)
{
    //ctor
}

void MessageReceiver::ConnectionReceived(Socket &pSocket) {
}

void MessageReceiver::ProcessMessage(RawData& pMessage) {
    std::string tMessage = pMessage.ToString();

    MessageFactory factory("../lib");
    Message *message = factory.BuildMessage(tMessage);

    MessageDispatcher *disp = new EvaluationSetMessageDispatcher(100);
    Message* reply = disp->DispatchMessage(message);

    delete message;
    delete reply;
}

MessageReceiver::~MessageReceiver()
{
    //dtor
}
